package com.tools.model;

import com.alibaba.fastjson.JSONObject;

/**
 * 基础信息配置文件
 *
 * @author  < a href=" ">ZhangYang</ a>
 * @version v1.0.01
 * @date    2018-07-31 14:12:44
 */

public class BaseModel {
  /** 生成模板的名字 */
  private String storagePath;
  /** 字段使用驼峰命名 */
  private String pkgPrefix;
  private String tablePrefix;
  private String module;
  private String author;
  private String version;
  private String encoding;
  private String entityTemp;
  private String daoTemp;
  private String serviceTemp;
  private String controllerTemp;

  /**
   * 实例化
   */
  public BaseModel() {
    super();
  }

  /**
   * 实例化
   *
   * @param obj
   */
  public BaseModel(JSONObject obj) {
    super();
    this.storagePath = obj.getString("storagePath");
    this.pkgPrefix = obj.getString("pkgPrefix");
    this.tablePrefix = obj.getString("tablePrefix");
    this.module = obj.getString("module");
    this.author = obj.getString("author");
    this.version = obj.getString("version");
    this.encoding = obj.getString("encoding");
    this.entityTemp = obj.getString("entityTemp");
    this.daoTemp = obj.getString("daoTemp");
    this.serviceTemp = obj.getString("serviceTemp");
    this.controllerTemp = obj.getString("controllerTemp");
  }

  /**
   * 将对象转换为JSONObject
   *
   * @return
   */
  public JSONObject toJson() {
    JSONObject result = new JSONObject();
    result.put("storagePath", storagePath);
    result.put("pkgPrefix", pkgPrefix);
    result.put("tablePrefix", tablePrefix);
    result.put("module", module);
    result.put("author", author);
    result.put("version", version);
    result.put("encoding", encoding);
    result.put("entityTemp", entityTemp);
    result.put("daoTemp", daoTemp);
    result.put("serviceTemp", serviceTemp);
    result.put("controllerTemp", controllerTemp);
    return result;
  }

  /**
   * 将当前对象转换为Json字符串
   *
   * @return
   */
  public String toJsonString() {
    return toJson().toJSONString();
  }

  public String getStoragePath() {
    return storagePath;
  }

  public void setStoragePath(String storagePath) {
    this.storagePath = storagePath;
  }

  public String getPkgPrefix() {
    return pkgPrefix;
  }

  public void setPkgPrefix(String pkgPrefix) {
    this.pkgPrefix = pkgPrefix;
  }

  public String getTablePrefix() {
    return tablePrefix;
  }

  public void setTablePrefix(String tablePrefix) {
    this.tablePrefix = tablePrefix;
  }

  public String getModule() {
    return module;
  }

  public void setModule(String module) {
    this.module = module;
  }

  public String getAuthor() {
    return author;
  }

  public void setAuthor(String author) {
    this.author = author;
  }

  public String getVersion() {
    return version;
  }

  public void setVersion(String version) {
    this.version = version;
  }

  public String getEncoding() {
    return encoding;
  }

  public void setEncoding(String encoding) {
    this.encoding = encoding;
  }

  public String getEntityTemp() {
    return entityTemp;
  }

  public void setEntityTemp(String entityTemp) {
    this.entityTemp = entityTemp;
  }

  public String getDaoTemp() {
    return daoTemp;
  }

  public void setDaoTemp(String daoTemp) {
    this.daoTemp = daoTemp;
  }

  public String getServiceTemp() {
    return serviceTemp;
  }

  public void setServiceTemp(String serviceTemp) {
    this.serviceTemp = serviceTemp;
  }

  public String getControllerTemp() {
    return controllerTemp;
  }

  public void setControllerTemp(String controllerTemp) {
    this.controllerTemp = controllerTemp;
  }

}
